<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>CodigoPostal</title>
 <link rel="stylesheet" href="../styles/style.css" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<script type="text/javascript">

var peticion = false;
   var  testPasado = false;
   try {
     peticion = new XMLHttpRequest();
     } catch (trymicrosoft) {
   try {
   peticion = new ActiveXObject("Msxml2.XMLHTTP");
   } catch (othermicrosoft) {
  try {
  peticion = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (failed) {
  peticion = false;
  }
  }
  }
  if (!peticion)
  alert("ERROR AL INICIALIZAR!");

     function changeAjax (url, comboAnterior, element_id) {
       var element =  document.getElementById(element_id);
       var valordepende = document.getElementById(comboAnterior)
       var x = valordepende.value
       if(url.indexOf('?') != -1) {
           var fragment_url = url+'&Id='+x;
       }else{
           var fragment_url = url+'?Id='+x;
       }
       element.innerHTML = 'Cargando...<!--<img src="Imagenes/loading.gif" />-->';
       peticion.open("GET", fragment_url);
       peticion.onreadystatechange = function() {
       if (peticion.readyState == 4) {
       element.innerHTML = peticion.responseText;
           }
       }
      peticion.send(null);
   }
  </script>
<?php

  require ("../../../configuracion.php");
  require ("../../../db.php");

$IdMunicipio= $_GET['id'];
$IdPregunta = $_GET['IdPregunta'];

$SelectColonia = mssql_query("SELECT distinct(st_Colonia),id_Colonia FROM ".$ecrmDB."..cat_Colonias WHERE id_Municipio = '$IdMunicipio' order by st_Colonia");
if($rowColonia = mssql_fetch_array($SelectColonia)) {

?>
<br>
<table width="90%" border="0" cellspacing="1" cellpadding="5" class="mainTableBG">
<tr class="fondoBlanco">
    <td><label>Colonia : </label></td>
    <td><select name="colonia" onChange="javascript:changeAjax('https://c3.cacto.com/mx/cacto/admin/guiones/ajax/CPostal2.php', 'codigo', 'Div_Codigos');" id="codigo" >
   <?php
   echo "<option value=\"9999\">Seleccione una colonia</option>";
   do{
        echo "<option value=\"".$rowColonia['id_Colonia']."\">".strtoupper($rowColonia['st_Colonia'])."</option>\n";
   }while($rowColonia = mssql_fetch_array($SelectColonia));
     ?>
   
   </select>
    </td>
</tr>

<tr class="fondoBlanco">
   <td>C.P.</td>
    <td><div id="Div_Codigos">Esperando la seleccion de la colonia ... </div></td>
</tr>
 
 <?php
}else{
 ?>
  <label>Colonia : </label><select name="colonia" id="codigo" >
        <option value="9999">No hay colonias</option>
		</select>
<?php
}
?>

</table>
</html>